package com.wedata.腾讯;

import cn.hutool.crypto.digest.MD5;
import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

import java.util.UUID;

public class 微信小程序 {

    public static void main(String[] args) {
        System.out.println(postRequestWithSign());
    }

    /**
     * 获取第三方平台的 AccessToken
     * @return
     * @throws Exception
     */
    protected static String postRequestWithSign() {
        JSONObject body = new JSONObject();
        body.set("appId", "wx81c8dd96b3f26059");
        body.set("enableProxy", false);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://wedata.gymcity.com.cn/openapi/third/getWeiXinToken", header, body);
        System.out.println(result);
        return result.getStr("data");
    }
}
